package cn.com.scitc.user;

import cn.com.scitc.dao.ManagerDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "UserDeleteServlet",urlPatterns = "/manager/user/delete")
public class UserDeleteServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        try{
            String id = request.getParameter("id");
            ManagerDao managerDao = new ManagerDao();
            managerDao.delete(Integer.parseInt(id));
            System.out.println("delete success!!");
            request.getSession().setAttribute("msg","删除用户成功");
            response.sendRedirect("list");
        }catch (Exception e){
            System.out.println("delete fail!");
            request.getSession().setAttribute("msg","删除用户失败");
            response.sendRedirect("list");
        }
    }
}
